﻿using System;

namespace Thuoc24h.Home.Pages
{
    public partial class Contact : BasePage.BasePages
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSend_OnClick(object sender, EventArgs e)
        {

            CaptchaControl1.ValidateCaptcha(txtCaptcha.Text.Trim());
            if (CaptchaControl1.UserValidated)
            {

                var contact = new Data.Contact
                {
                    Name = txtName.Text,
                    Email = txtEmail.Text,
                    Address = txtAddress.Text,
                    PhoneNumber = txtPhone.Text,
                    Detail = txtDetail.Text,
                    CreatedDate = DateTime.Now,
                    IsRead = false,
                    TypeRequest =1
                    
                };
                context.Contacts.AddObject(contact);
                int save = context.SaveChanges();
                if (save > 0)
                {
                
                    txtName.Text = txtEmail.Text = txtAddress.Text = txtPhone.Text = txtDetail.Text = txtCaptcha.Text = string.Empty;
                    ClientScript.RegisterStartupScript(this.GetType(), "Thông báo", "alert('" + "Gửi liên hệ thành công" + "');", true);
                }

            }
        }
    }
}